package com.gitee.wsl.struct.grammar.ast.process.constraints.ext

import com.gitee.wsl.struct.grammar.ast.process.constraints.TextReadConstraints


fun TextReadConstraints.extendsList(other: TextReadConstraints): Boolean {
    if (other.types.isEmpty()) {
        throw IllegalArgumentException("List constraints should contain at least one item")
    }
    return startsWith(other) && !containsListMarkers(other.types.size - 1)
}

fun TextReadConstraints.extendsPrev(other: TextReadConstraints): Boolean {
    return startsWith(other) && !containsListMarkers(other.types.size)
}

fun TextReadConstraints.upstreamWith(other: TextReadConstraints): Boolean {
    return other.startsWith(this) && !containsListMarkers()
}

